home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / include / coff / ecoff.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-04  |  14.5 KB  |  421 lines

  1. #ifndef ECOFF_H
  2. #define ECOFF_H
  3.  
  4. /* Generic ECOFF support.
  5.    This does not include symbol information, found in sym.h and
  6.    symconst.h.  */
  7.  
  8. /* Mips magic numbers used in filehdr.  MIPS_MAGIC_LITTLE is used on
  9.    little endian machines.  MIPS_MAGIC_BIG is used on big endian
  10.    machines.  Where is MIPS_MAGIC_1 from?  */
  11. #define MIPS_MAGIC_1 0x0180
  12. #define MIPS_MAGIC_LITTLE 0x0162
  13. #define MIPS_MAGIC_BIG 0x0160
  14.  
  15. /* These are the magic numbers used for MIPS code compiled at ISA
  16.    level 2.  */
  17. #define MIPS_MAGIC_LITTLE2 0x0166
  18. #define MIPS_MAGIC_BIG2 0x0163
  19.  
  20. /* These are the magic numbers used for MIPS code compiled at ISA
  21.    level 3.  */
  22. #define MIPS_MAGIC_LITTLE3 0x142
  23. #define MIPS_MAGIC_BIG3 0x140
  24.  
  25. /* Alpha magic numbers used in filehdr.  */
  26. #define ALPHA_MAGIC 0x183
  27.  
  28. /* Magic numbers used in a.out header.  */
  29. #define ECOFF_AOUT_OMAGIC 0407    /* not demand paged (ld -N).  */
  30. #define ECOFF_AOUT_ZMAGIC 0413    /* demand load format, eg normal ld output */
  31.  
  32. /* Names of special sections.  */
  33. #define _TEXT   ".text"
  34. #define _DATA   ".data"
  35. #define _BSS    ".bss"
  36. #define _RDATA    ".rdata"
  37. #define _SDATA    ".sdata"
  38. #define _SBSS    ".sbss"
  39. #define _LITA    ".lita"
  40. #define _LIT4    ".lit4"
  41. #define _LIT8    ".lit8"
  42. #define _LIB    ".lib"
  43. #define _INIT    ".init"
  44. #define _FINI    ".fini"
  45. #define _PDATA    ".pdata"
  46. #define _XDATA    ".xdata"
  47. #define _GOT    ".got"
  48. #define _HASH    ".hash"
  49. #define _DYNSYM    ".dynsym"
  50. #define _DYNSTR    ".dynstr"
  51. #define _RELDYN    ".rel.dyn"
  52. #define _CONFLIC ".conflic"
  53. #define _COMMENT ".comment"
  54. #define _LIBLIST ".liblist"
  55. #define _DYNAMIC ".dynamic"
  56. #define _RCONST    ".rconst"
  57.  
  58. /* ECOFF uses some additional section flags.  */
  59. #define STYP_RDATA         0x100
  60. #define STYP_SDATA         0x200
  61. #define STYP_SBSS         0x400
  62. #define STYP_GOT        0x1000
  63. #define STYP_DYNAMIC        0x2000
  64. #define STYP_DYNSYM        0x4000
  65. #define STYP_RELDYN        0x8000
  66. #define STYP_DYNSTR       0x10000
  67. #define STYP_HASH       0x20000
  68. #define STYP_LIBLIST       0x40000
  69. #define STYP_CONFLIC      0x100000
  70. #define STYP_ECOFF_FINI     0x1000000
  71. #define STYP_EXTENDESC     0x2000000 /* 0x02FFF000 bits => scn type, rest clr */
  72. #define STYP_LITA     0x4000000
  73. #define STYP_LIT8     0x8000000
  74. #define STYP_LIT4    0x10000000
  75. #define STYP_ECOFF_LIB    0x40000000
  76. #define STYP_ECOFF_INIT 0x80000000
  77. #define STYP_OTHER_LOAD (STYP_ECOFF_INIT | STYP_ECOFF_FINI)
  78.  
  79. /* extended section types */
  80. #define STYP_COMMENT     0x2100000
  81. #define STYP_RCONST     0x2200000
  82. #define STYP_XDATA     0x2400000
  83. #define STYP_PDATA     0x2800000
  84.  
  85. /* The linker needs a section to hold small common variables while
  86.    linking.  There is no convenient way to create it when the linker
  87.    needs it, so we always create one for each BFD.  We then avoid
  88.    writing it out.  */
  89. #define SCOMMON ".scommon"
  90.  
  91. /* If the extern bit in a reloc is 1, then r_symndx is an index into
  92.    the external symbol table.  If the extern bit is 0, then r_symndx
  93.    indicates a section, and is one of the following values.  */
  94. #define RELOC_SECTION_NONE    0
  95. #define RELOC_SECTION_TEXT    1
  96. #define RELOC_SECTION_RDATA    2
  97. #define RELOC_SECTION_DATA    3
  98. #define RELOC_SECTION_SDATA    4
  99. #define RELOC_SECTION_SBSS    5
  100. #define RELOC_SECTION_BSS    6
  101. #define RELOC_SECTION_INIT    7
  102. #define RELOC_SECTION_LIT8    8
  103. #define RELOC_SECTION_LIT4    9
  104. #define RELOC_SECTION_XDATA    10
  105. #define RELOC_SECTION_PDATA    11
  106. #define RELOC_SECTION_FINI     12
  107. #define RELOC_SECTION_LITA     13
  108. #define RELOC_SECTION_ABS      14
  109. #define RELOC_SECTION_RCONST   15
  110.  
  111. #define NUM_RELOC_SECTIONS     16
  112.  
  113. /********************** STABS **********************/
  114.  
  115. /* gcc uses mips-tfile to output type information in special stabs
  116.    entries.  These must match the corresponding definition in
  117.    gcc/config/mips.h.  At some point, these should probably go into a
  118.    shared include file, but currently gcc and gdb do not share any
  119.    directories. */
  120. #define CODE_MASK 0x8F300
  121. #define ECOFF_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
  122. #define ECOFF_MARK_STAB(code) ((code)+CODE_MASK)
  123. #define ECOFF_UNMARK_STAB(code) ((code)-CODE_MASK)
  124. #define STABS_SYMBOL "@stabs"
  125.  
  126. /********************** COFF **********************/
  127.  
  128. /* gcc also uses mips-tfile to output COFF debugging information.
  129.    These are the values it uses when outputting the .type directive.
  130.    These should also be in a shared include file.  */
  131. #define N_BTMASK    (017)
  132. #define N_TMASK        (060)
  133. #define N_BTSHFT    (4)
  134. #define N_TSHIFT    (2)
  135.  
  136. /********************** AUX **********************/
  137.  
  138. /* The auxiliary type information is the same on all known ECOFF
  139.    targets.  I can't see any reason that it would ever change, so I am
  140.    going to gamble and define the external structures here, in the
  141.    target independent ECOFF header file.  The internal forms are
  142.    defined in coff/sym.h, which was originally donated by MIPS
  143.    Computer Systems.  */
  144.  
  145. /* Type information external record */
  146.  
  147. struct tir_ext {
  148.     unsigned char    t_bits1[1];
  149.     unsigned char    t_tq45[1];
  150.     unsigned char    t_tq01[1];
  151.     unsigned char    t_tq23[1];
  152. };
  153.  
  154. #define    TIR_BITS1_FBITFIELD_BIG        ((unsigned int) 0x80)
  155. #define    TIR_BITS1_FBITFIELD_LITTLE    ((unsigned int) 0x01)
  156.  
  157. #define    TIR_BITS1_CONTINUED_BIG        ((unsigned int) 0x40)
  158. #define    TIR_BITS1_CONTINUED_LITTLE    ((unsigned int) 0x02)
  159.  
  160. #define    TIR_BITS1_BT_BIG        ((unsigned int) 0x3F)
  161. #define    TIR_BITS1_BT_SH_BIG        0
  162. #define    TIR_BITS1_BT_LITTLE        ((unsigned int) 0xFC)
  163. #define    TIR_BITS1_BT_SH_LITTLE        2
  164.  
  165. #define    TIR_BITS_TQ4_BIG        ((unsigned int) 0xF0)
  166. #define    TIR_BITS_TQ4_SH_BIG        4
  167. #define    TIR_BITS_TQ5_BIG        ((unsigned int) 0x0F)
  168. #define    TIR_BITS_TQ5_SH_BIG        0
  169. #define    TIR_BITS_TQ4_LITTLE        ((unsigned int) 0x0F)
  170. #define    TIR_BITS_TQ4_SH_LITTLE        0
  171. #define    TIR_BITS_TQ5_LITTLE        ((unsigned int) 0xF0)
  172. #define    TIR_BITS_TQ5_SH_LITTLE        4
  173.  
  174. #define    TIR_BITS_TQ0_BIG        ((unsigned int) 0xF0)
  175. #define    TIR_BITS_TQ0_SH_BIG        4
  176. #define    TIR_BITS_TQ1_BIG        ((unsigned int) 0x0F)
  177. #define    TIR_BITS_TQ1_SH_BIG        0
  178. #define    TIR_BITS_TQ0_LITTLE        ((unsigned int) 0x0F)
  179. #define    TIR_BITS_TQ0_SH_LITTLE        0
  180. #define    TIR_BITS_TQ1_LITTLE        ((unsigned int) 0xF0)
  181. #define    TIR_BITS_TQ1_SH_LITTLE        4
  182.  
  183. #define    TIR_BITS_TQ2_BIG        ((unsigned int) 0xF0)
  184. #define    TIR_BITS_TQ2_SH_BIG        4
  185. #define    TIR_BITS_TQ3_BIG        ((unsigned int) 0x0F)
  186. #define    TIR_BITS_TQ3_SH_BIG        0
  187. #define    TIR_BITS_TQ2_LITTLE        ((unsigned int) 0x0F)
  188. #define    TIR_BITS_TQ2_SH_LITTLE        0
  189. #define    TIR_BITS_TQ3_LITTLE        ((unsigned int) 0xF0)
  190. #define    TIR_BITS_TQ3_SH_LITTLE        4
  191.  
  192. /* Relative symbol external record */
  193.  
  194. struct rndx_ext {
  195.     unsigned char    r_bits[4];
  196. };
  197.  
  198. #define    RNDX_BITS0_RFD_SH_LEFT_BIG    4
  199. #define    RNDX_BITS1_RFD_BIG        ((unsigned int) 0xF0)
  200. #define    RNDX_BITS1_RFD_SH_BIG        4
  201.  
  202. #define    RNDX_BITS0_RFD_SH_LEFT_LITTLE    0
  203. #define    RNDX_BITS1_RFD_LITTLE        ((unsigned int) 0x0F)
  204. #define    RNDX_BITS1_RFD_SH_LEFT_LITTLE    8
  205.  
  206. #define    RNDX_BITS1_INDEX_BIG        ((unsigned int) 0x0F)
  207. #define    RNDX_BITS1_INDEX_SH_LEFT_BIG    16
  208. #define    RNDX_BITS2_INDEX_SH_LEFT_BIG    8
  209. #define    RNDX_BITS3_INDEX_SH_LEFT_BIG    0
  210.  
  211. #define    RNDX_BITS1_INDEX_LITTLE        ((unsigned int) 0xF0)
  212. #define    RNDX_BITS1_INDEX_SH_LITTLE    4
  213. #define    RNDX_BITS2_INDEX_SH_LEFT_LITTLE    4
  214. #define    RNDX_BITS3_INDEX_SH_LEFT_LITTLE    12
  215.  
  216. /* Auxiliary symbol information external record */
  217.  
  218. union aux_ext {
  219.     struct tir_ext    a_ti;
  220.     struct rndx_ext    a_rndx;
  221.     unsigned char    a_dnLow[4];
  222.     unsigned char    a_dnHigh[4];
  223.     unsigned char    a_isym[4];
  224.     unsigned char    a_iss[4];
  225.     unsigned char    a_width[4];
  226.     unsigned char    a_count[4];
  227. };
  228.  
  229. #define AUX_GET_ANY(bigend, ax, field) \
  230.   ((bigend) ? bfd_getb32 ((ax)->field) : bfd_getl32 ((ax)->field))
  231.  
  232. #define    AUX_GET_DNLOW(bigend, ax)    AUX_GET_ANY ((bigend), (ax), a_dnLow)
  233. #define    AUX_GET_DNHIGH(bigend, ax)    AUX_GET_ANY ((bigend), (ax), a_dnHigh)
  234. #define    AUX_GET_ISYM(bigend, ax)    AUX_GET_ANY ((bigend), (ax), a_isym)
  235. #define AUX_GET_ISS(bigend, ax)        AUX_GET_ANY ((bigend), (ax), a_iss)
  236. #define AUX_GET_WIDTH(bigend, ax)    AUX_GET_ANY ((bigend), (ax), a_width)
  237. #define AUX_GET_COUNT(bigend, ax)    AUX_GET_ANY ((bigend), (ax), a_count)
  238.  
  239. #define AUX_PUT_ANY(bigend, val, ax, field) \
  240.   ((bigend) \
  241.    ? (bfd_putb32 ((bfd_vma) (val), (ax)->field), 0) \
  242.    : (bfd_putl32 ((bfd_vma) (val), (ax)->field), 0))
  243.  
  244. #define AUX_PUT_DNLOW(bigend, val, ax) \
  245.   AUX_PUT_ANY ((bigend), (val), (ax), a_dnLow)
  246. #define AUX_PUT_DNHIGH(bigend, val, ax) \
  247.   AUX_PUT_ANY ((bigend), (val), (ax), a_dnHigh)
  248. #define AUX_PUT_ISYM(bigend, val, ax) \
  249.   AUX_PUT_ANY ((bigend), (val), (ax), a_isym)
  250. #define AUX_PUT_ISS(bigend, val, ax) \
  251.   AUX_PUT_ANY ((bigend), (val), (ax), a_iss)
  252. #define AUX_PUT_WIDTH(bigend, val, ax) \
  253.   AUX_PUT_ANY ((bigend), (val), (ax), a_width)
  254. #define AUX_PUT_COUNT(bigend, val, ax) \
  255.   AUX_PUT_ANY ((bigend), (val), (ax), a_count)
  256.  
  257. /********************** SYMBOLS **********************/
  258.  
  259. /* For efficiency, gdb deals directly with the unswapped symbolic
  260.    information (that way it only takes the time to swap information
  261.    that it really needs to read).  gdb originally retrieved the
  262.    information directly from the BFD backend information, but that
  263.    strategy, besides being sort of ugly, does not work for MIPS ELF,
  264.    which also uses ECOFF debugging information.  This structure holds
  265.    pointers to the (mostly) unswapped symbolic information.  */
  266.  
  267. struct ecoff_debug_info
  268. {
  269.   /* The swapped ECOFF symbolic header.  */
  270.   HDRR symbolic_header;
  271.  
  272.   /* Pointers to the unswapped symbolic information.  Note that the
  273.      pointers to external structures point to different sorts of
  274.      information on different ECOFF targets.  The ecoff_debug_swap
  275.      structure provides the sizes of the structures and the functions
  276.      needed to swap the information in and out.  These pointers are
  277.      all pointers to arrays, not single structures.  They will be NULL
  278.      if there are no instances of the relevant structure.  These
  279.      fields are also used by the assembler to output ECOFF debugging
  280.      information.  */
  281.   unsigned char *line;
  282.   PTR external_dnr;    /* struct dnr_ext */
  283.   PTR external_pdr;    /* struct pdr_ext */
  284.   PTR external_sym;    /* struct sym_ext */
  285.   PTR external_opt;    /* struct opt_ext */
  286.   union aux_ext *external_aux;
  287.   char *ss;
  288.   char *ssext;
  289.   PTR external_fdr;    /* struct fdr_ext */
  290.   PTR external_rfd;    /* struct rfd_ext */
  291.   PTR external_ext;    /* struct ext_ext */
  292.  
  293.   /* These fields are used when linking.  They may disappear at some
  294.      point.  */
  295.   char *ssext_end;
  296.   PTR external_ext_end;
  297.  
  298.   /* When linking, this field holds a mapping from the input FDR
  299.      numbers to the output numbers, and is used when writing out the
  300.      external symbols.  It is NULL if no mapping is required.  */
  301.   RFDT *ifdmap;
  302.  
  303.   /* The swapped FDR information.  Currently this is never NULL, but
  304.      code using this structure should probably double-check in case
  305.      this changes in the future.  This is a pointer to an array, not a
  306.      single structure.  */
  307.   FDR *fdr;
  308.  
  309.   /* When relaxing MIPS embedded PIC code, we may need to adjust
  310.      symbol values when they are output.  This is a linked list of
  311.      structures indicating how values should be adjusted.  There is no
  312.      requirement that the entries be in any order, or that they not
  313.      overlap.  This field is normally NULL, in which case no
  314.      adjustments need to be made.  */
  315.   struct ecoff_value_adjust *adjust;
  316. };
  317.  
  318. /* This structure describes how to adjust symbol values when
  319.    outputting MIPS embedded PIC code.  These adjustments only apply to
  320.    the internal symbols, as the external symbol values will come from
  321.    the hash table and have already been adjusted.  */
  322.  
  323. struct ecoff_value_adjust
  324. {
  325.   /* Next entry on adjustment list.  */
  326.   struct ecoff_value_adjust *next;
  327.   /* Starting VMA of adjustment.  This is the VMA in the ECOFF file,
  328.      not the offset from the start of the section.  Thus it should
  329.      indicate a particular section.  */
  330.   bfd_vma start;
  331.   /* Ending VMA of adjustment.  */
  332.   bfd_vma end;
  333.   /* Adjustment.  This should be added to the value of the symbol, or
  334.      FDR.  This is zero for the last entry in the array.  */
  335.   long adjust;
  336. };
  337.  
  338. /* These structures are used by the ECOFF find_nearest_line function.  */
  339.  
  340. struct ecoff_fdrtab_entry
  341. {
  342.   /* Base address in .text of this FDR.  */
  343.   bfd_vma base_addr;
  344.   FDR *fdr;
  345. };
  346.  
  347. struct ecoff_find_line
  348. {
  349.   /* Allocated memory to hold function and file names.  */
  350.   char *find_buffer;
  351.  
  352.   /* FDR table, sorted by address: */
  353.   long fdrtab_len;
  354.   struct ecoff_fdrtab_entry *fdrtab;
  355.  
  356.   /* Cache entry for most recently found line information.  The sect
  357.      field is NULL if this cache does not contain valid information.  */
  358.   struct
  359.     {
  360.       asection *sect;
  361.       bfd_vma start;
  362.       bfd_vma stop;
  363.       const char *filename;
  364.       const char *functionname;
  365.       unsigned int line_num;
  366.     } cache;
  367. };
  368.  
  369. /********************** SWAPPING **********************/
  370.  
  371. /* The generic ECOFF code needs to be able to swap debugging
  372.    information in and out in the specific format used by a particular
  373.    ECOFF implementation.  This structure provides the information
  374.    needed to do this.  */
  375.  
  376. struct ecoff_debug_swap
  377. {
  378.   /* Symbol table magic number.  */
  379.   int sym_magic;
  380.   /* Alignment of debugging information.  E.g., 4.  */
  381.   bfd_size_type debug_align;
  382.   /* Sizes of external symbolic information.  */
  383.   bfd_size_type external_hdr_size;
  384.   bfd_size_type external_dnr_size;
  385.   bfd_size_type external_pdr_size;
  386.   bfd_size_type external_sym_size;
  387.   bfd_size_type external_opt_size;
  388.   bfd_size_type external_fdr_size;
  389.   bfd_size_type external_rfd_size;
  390.   bfd_size_type external_ext_size;
  391.   /* Functions to swap in external symbolic data.  */
  392.   void (*swap_hdr_in) PARAMS ((bfd *, PTR, HDRR *));
  393.   void (*swap_dnr_in) PARAMS ((bfd *, PTR, DNR *));
  394.   void (*swap_pdr_in) PARAMS ((bfd *, PTR, PDR *));
  395.   void (*swap_sym_in) PARAMS ((bfd *, PTR, SYMR *));
  396.   void (*swap_opt_in) PARAMS ((bfd *, PTR, OPTR *));
  397.   void (*swap_fdr_in) PARAMS ((bfd *, PTR, FDR *));
  398.   void (*swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *));
  399.   void (*swap_ext_in) PARAMS ((bfd *, PTR, EXTR *));
  400.   void (*swap_tir_in) PARAMS ((int, const struct tir_ext *, TIR *));
  401.   void (*swap_rndx_in) PARAMS ((int, const struct rndx_ext *, RNDXR *));
  402.   /* Functions to swap out external symbolic data.  */
  403.   void (*swap_hdr_out) PARAMS ((bfd *, const HDRR *, PTR));
  404.   void (*swap_dnr_out) PARAMS ((bfd *, const DNR *, PTR));
  405.   void (*swap_pdr_out) PARAMS ((bfd *, const PDR *, PTR));
  406.   void (*swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR));
  407.   void (*swap_opt_out) PARAMS ((bfd *, const OPTR *, PTR));
  408.   void (*swap_fdr_out) PARAMS ((bfd *, const FDR *, PTR));
  409.   void (*swap_rfd_out) PARAMS ((bfd *, const RFDT *, PTR));
  410.   void (*swap_ext_out) PARAMS ((bfd *, const EXTR *, PTR));
  411.   void (*swap_tir_out) PARAMS ((int, const TIR *, struct tir_ext *));
  412.   void (*swap_rndx_out) PARAMS ((int, const RNDXR *, struct rndx_ext *));
  413.   /* Function to read symbol data and set up pointers in
  414.      ecoff_debug_info structure.  The section argument is used for
  415.      ELF, not straight ECOFF.  */
  416.   boolean (*read_debug_info) PARAMS ((bfd *, asection *,
  417.                       struct ecoff_debug_info *));
  418. };
  419.  
  420. #endif /* ! defined (ECOFF_H) */
  421.